package com.hpjz.emrecord.web.controller;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import lombok.extern.log4j.Log4j;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hpjz.common.ParameterBean;
import com.hpjz.common.ResultBean;
import com.hpjz.common.utils.ConstantDefinition;
import com.hpjz.emrecord.service.IEmRecordService;
import com.hpjz.emrecord.service.IEmRecordStatisService;
import com.hpjz.emrecord.web.vo.EmRecordStatisVO;
import com.hpjz.emrecord.web.vo.GpsInfoVO;
/**
 * 
 * 病历统计信息
 * 
 * @author bbchen
 *
 */
@Controller
@RequestMapping("/emRecordStatis")
@Log4j
public class EmRecordStatisController {
	
	@Resource
	private IEmRecordStatisService emRecordStatisService;
	
	
	//TODO:传入用户编号。如果是android不让登录。
	@RequestMapping(value = "/recordStatis",method = RequestMethod.POST)
	public @ResponseBody ResultBean insertGpsInfo(@RequestBody ParameterBean pb){
		ResultBean result = new ResultBean();
		String platform = pb.getPlatform();
		String uid = pb.getUid();
		if (!ConstantDefinition.CLIENT_PLATFORM.equalsIgnoreCase(platform)) {
			result.setStatus(ConstantDefinition.USER_FORBID);
			result.setResult("用户禁止访问!");
			return result;
		}
		
		 try {
			 System.out.println("=============执行到了这里=============");
			 Map map = new HashMap<>();
			 map.put("uid", uid);
			 map.put("platform", platform);
			 Map dataMap = this.emRecordStatisService.findEmStatis(map);
			 if (dataMap.get("error")!=null) {
				 result.setStatus(ConstantDefinition.USER_FORBID);
				 result.setResult("用户禁止访问!");
				return result;
			 }
			 
			 result.setResult(dataMap.get("data"));
			 result.setStatus(ConstantDefinition.SYSTEM_SUCCESS);
		} catch (Exception e) {
			 log.error("查询电子病历统计信息失败！",e);
			 result.setStatus(ConstantDefinition.SYSTEM_ERROR);
		}
		 return result;
	}

}
